package com.example.demo.mvvm.net;

import com.example.demo.mvvm.bean.ArticleBean;
import com.example.demo.mvvm.bean.BannerBean;
import com.example.demo.mvvm.bean.BaseDto;
import com.example.demo.mvvm.bean.HotKeyBean;
import com.example.demo.mvvm.bean.KnowBean;
import com.example.demo.mvvm.bean.ListDto;
import com.example.demo.mvvm.bean.UserBean;

import java.util.List;

import io.reactivex.Observable;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

/**
 * Created by 80711 on 2018/5/16.
 */

public interface ApiService {

    @GET("article/list/{pageNum}/json")
    Observable<BaseDto<ListDto<ArticleBean>>> getHomeArticle(@Path("pageNum") int pageNum);

    @GET("banner/json")
    Observable<BaseDto<List<BannerBean>>> getHomeBannerInfo();

    @GET("tree/json")
    Observable<BaseDto<List<KnowBean>>> getKnowInfo();

    //http://www.wanandroid.com/article/list/0/json?cid=60
    @GET("article/list/{pageNum}/json")
    Observable<BaseDto<ListDto<ArticleBean>>> getKownChildrenArticle(@Path("pageNum") int pageNum , @Query("cid") String cid);

    @GET("hotkey/json")
    Observable<BaseDto<List<HotKeyBean>>> getHotKeyDatas();

    @POST("article/query/{pageNum}/json")
    Observable<BaseDto<ListDto<ArticleBean>>> getSearchDatas(@Path("pageNum") int pageNum , @Query("k") String keyWord);

    @POST("user/login")
    Observable<BaseDto<UserBean>> login(@Query("username") String username , @Query("password") String password);

    @POST("user/register")
    Observable<BaseDto<UserBean>> register(@Query("username") String username , @Query("password") String password , @Query("repassword") String repassword);

    @POST("lg/collect/{id}/json")
    Observable<BaseDto> addcollect(@Path("id") int id);

    @POST("lg/uncollect/{id}/json")
    Observable<BaseDto> removeCollect(@Path("id") int id , @Query("originId") int originId);
}
